<?php

class Tarea_Form_Add extends Zend_Form {

    public function init() {


        $this->setName('form_tarea');
        $this->setMethod('post');

        // username
        $title = new Zend_Form_Element_Text('title');
        $title->setLabel('Titulo')
                ->setRequired(true)
                ->addFilter('StripTags')
                ->addFilter('StringTrim')
                ->addFilter('StringToLower')
                ->addValidator('NotEmpty', true, array('messages' => 'Ingrese un titulo'));




        $desc = new Zend_Form_Element_Textarea('description');
        $desc->setLabel('Descripcion')
                ->setRequired(true)
                ->setAttrib('rows', 10)
                ->setAttrib('cols', 50)
                ->addFilter('StripTags')
                ->addFilter('StringTrim')
                ->addValidator('NotEmpty', true, array('messages' => 'Ingrese una descripcion'));

        $desc_end = new Zend_Form_Element_Textarea('description_end');
        $desc_end->setAttrib("style", "display:none")
                ->setRequired(false)
                ->addFilter('StripTags')
                ->addFilter('StringTrim')
                ->addValidator('NotEmpty', true, array('messages' => 'Seleccione el grupo'));

        $dateValidator = new Zend_Validate_Date('dd-mm-yyyy');


        $fechai = new Zend_Form_Element_Text('create_date');
        $fechai->setLabel('Fecha inicio')
                ->setRequired(true)
                ->addFilter('StripTags')
                ->addFilter('StringTrim')
                ->addFilter('StringToLower')
                ->addValidator('NotEmpty', true, array('messages' => 'Ingrese la fecha de creacion'))
                ->addValidator($dateValidator, true, array('messages' => 'Fecha incorrecta'));


        $fechaf = new Zend_Form_Element_Text('end_date');
        $fechaf->setLabel('Fecha Finalizacion')
                ->setRequired(true)
                ->addFilter('StripTags')
                ->addFilter('StringTrim')
                ->addFilter('StringToLower')
                ->addValidator('NotEmpty', true, array('messages' => 'Ingrese la fecha de finalizacion'))
                ->addValidator($dateValidator, true, array('messages' => 'Fecha incorrecta'));


        $fechac = new Zend_Form_Element_Hidden('complete_date');
        $fechac
                ->setRequired(false)
                ->addFilter('StripTags')
                ->addFilter('StringTrim')
                ->addFilter('StringToLower')
                ->addValidator('NotEmpty', true, array('messages' => 'error'));


        $fechau = new Zend_Form_Element_Hidden('update_date');
        $fechau
                ->setRequired(false)
                ->addFilter('StripTags')
                ->addFilter('StringTrim')
                ->addFilter('StringToLower')
                ->addValidator('NotEmpty', true, array('messages' => 'error'));


        $del = new Zend_Form_Element_Hidden('delete');
        $del
                ->setRequired(false)
                ->addFilter('StripTags')
                ->addFilter('StringTrim')
                ->addFilter('StringToLower')
                ->addValidator('NotEmpty', true, array('messages' => 'error'));


        $estado = new Zend_Form_Element_Checkbox('status');
        $estado->setLabel('Estado')
                ->setRequired(true)
                ->addFilter('StripTags')
                ->addFilter('StringTrim')
                ->addValidator('NotEmpty', true, array('messages' => 'error'));


//        $idalcance = new Zend_Form_Element_Select('id_alcance');
//        $idalcance->setLabel('Alcance')
//                ->setRequired(true)
//                ->addFilter('StripTags')
//                ->addFilter('StringTrim')
//                ->addFilter('StringToLower')
//                ->addMultiOptions(array(
//                    "" => "-- Seleccione --"
//                ))
//                ->addValidator('NotEmpty', true, array('messages' => 'error'));


        $user_assig = new Zend_Form_Element_Select('id_user_assigned');
        $user_assig->setLabel('Usuario Asignado')
                ->setRequired(true)
                ->addFilter('StripTags')
                ->addFilter('StringTrim')
                ->addFilter('StringToLower')
                ->addMultiOptions(array(
                    "" => "-- Seleccione --"
                ))
                ->addValidator('NotEmpty', true, array('messages' => 'Seleccione un usuario'));


        $idorden = new Zend_Form_Element_Hidden('id_orden');
        $idorden
                ->setRequired(false)
                ->addFilter('StripTags')
                ->addFilter('StringTrim')
                ->addFilter('StringToLower')
                ->addValidator('NotEmpty', true, array('messages' => 'Ingrese su nombre de usuario'));

        $user_create = new Zend_Form_Element_Hidden('id_user_create');
        $user_create
                ->setRequired(false)
                ->addFilter('StripTags')
                ->addFilter('StringTrim')
                ->addFilter('StringToLower')
                ->addValidator('NotEmpty', true, array('messages' => 'Error'));



        // submit
        $submit = new Zend_Form_Element_Submit('submit');
        $submit->setLabel('Ingresar');

        $fin = new Zend_Form_Element_Submit('finalizar');
        $fin->setLabel('Finalizar');



        // add elements
        $this->addElements(array($title, $desc, $fechai, $fechaf, $estado, $user_assig, $submit, $fin, $idorden, $user_create, $desc_end, $fechac, $fechau, $del));
    }

}